using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class ItemPurReqControl
    {
		#region Local Variable
        private ItemPurReqDataAccess _objDAO;
		#endregion Local Variable
		
		#region Method
        public ItemPurReqControl()
        {
            _objDAO = new ItemPurReqDataAccess();
        }
		
		public object BeginTransaction(ref string sErr)
        {
            return _objDAO.BeginTransaction(ref sErr);
        }
        public bool CommitTransaction(ref string sErr)
        {
            return _objDAO.CommitTransaction(ref sErr);
        }
        public bool RollbackTransaction(ref string sErr)
        {
            return _objDAO.RollbackTransaction(ref sErr);
        }
        public void SetTransaction(object o)
        {
            _objDAO.SetTransaction(o);
        }
		
		public ItemPurReqInfo Get(
        String DTB,
        String RequestRef,
		ref string sErr)
        {
            return _objDAO.Get(
            DTB,
            RequestRef,
			ref sErr);
        }
		
        public DataTable GetAll(
        String DTB,
        ref string sErr)
        {
            return _objDAO.GetAll(
            DTB,
            ref sErr);
        }
		public DataTable GetByPos(
        String DTB,
        int pos, ref string sErr)
        {
            return _objDAO.GetByPos(
            DTB,
            pos, ref sErr);
        }
		public int GetCountRecord(
        String DTB,
        ref string sErr)
        {
            return _objDAO.GetCountRecord(
            DTB,
            ref sErr);
        }
		
        public Int32 Add(ItemPurReqInfo obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }
		
        public string Update(ItemPurReqInfo obj)
        {
            return _objDAO.Update(obj);
        }
		
        public string Delete(
        String DTB,
        String RequestRef
		)
        {
            return _objDAO.Delete(
            DTB,
            RequestRef
			);
			
        }  
        public Boolean IsExist(
        String DTB,
        String RequestRef
		)
        {
            return _objDAO.IsExist(
            DTB,
            RequestRef
			);
        } 
		
        public DataTable Search(String columnName, String columnValue, String condition, String tableName, ref String sErr)
        {           
            return _objDAO.Search(columnName, columnValue, condition, tableName, ref  sErr);
        }
        public string InsertUpdate(ItemPurReqInfo obj)
        {
            string sErr = "";
            if (IsExist(
            obj.DTB,
            obj.RequestRef
			))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }
		
        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
			return ItemPurReqInfo.ToDataTable();             
        }
		
		public string TransferIn(DataRow row)
        {
            ItemPurReqInfo inf = new ItemPurReqInfo(row);
            return InsertUpdate(inf);
        }
		#endregion Method


        public DataTable GetbyFilter(string db, string strFilter, ref string sErr)
        {
            return _objDAO.GetbyFilter(db, strFilter, ref  sErr);
        }
    }
}
